class: center, middle, inverse, title-slide .title[ # Data Literacy: Introduction to R ] .subtitle[ ## Outlook ] .author[ ### Veronika Batzdorfer ] .date[ ### 2024-11-21 ] --- layout: true --- ## Our jou`R`ney this week (hopefully) <img src="data:image/png;base64,#../img/r_pkgs_mindblowing.png" width="85%" style="display: block; margin: auto;" /> .footnote[[Source](https://res.cloudinary.com/syknapptic/image/upload/v1521320144/tidyverse_meme_oceake.png)] --- ## Resources: Introductory books [R for Data Science](https://r4ds.had.co.nz/) by Hadley Wickham [R Cookbook: Proven recipes for data analysis, statistics, and graphics](https://rc2e.com/) by JD Long & Paul Teetor [Hands-On Programming with R](https://rstudio-education.github.io/hopr/) by Garrett Grolemund [R Programming for Data Science](https://bookdown.org/rdpeng/rprogdatascience/) by Roger D. Peng [Quantitative Social Science Data with R](https://uk.sagepub.com/en-gb/eur/quantitative-social-science-data-with-r/book257236) by Brian J. Fogarty [Introduction to R for Social Scientists - A Tidy Programming Approach](https://www.routledge.com/Introduction-to-R-for-Social-Scientists-A-Tidy-Programming-Approach/Kennedy-Waggoner/p/book/9780367460723) by Ryan Kennedy & Philip D. Waggoner [Quantitative Social Science: An Introduction in tidyverse](https://press.princeton.edu/books/hardcover/9780691222271/quantitative-social-science) by Kosuke Imai & Nora Webb Williams --- ## Resources: Online courses & tutorials - Overview of resources - [*learnR4free*](https://www.learnr4free.com/) by Mine Dogucu - the [*Big Book of R*](https://www.bigbookofr.com/) by Oscar Baruffa - [*swirl* - Learn `R` in `R`](https://swirlstats.com/) - Learning `R` (and statistics) with a cute story: [Teacups, Giraffes, & Statistics by Hasse Wallum & Desirée de Leon](https://tinystats.github.io/teacups-giraffes-and-statistics/) --- ## Working with text data in `R` As with almost everything else, there are many great resources for working with text data in `R`. Two good options (and starting points) are: - the [`tidytext` package](https://juliasilge.github.io/tidytext/) and the "accompanying" book [*Text Mining with R: A Tidy Approach*](https://www.tidytextmining.com/) by Julia Silge & David Robinson - the [`quanteda` package](https://quanteda.io/) and its accompanying [tutorials](https://tutorials.quanteda.io/) - a nice and free self-paced online course is [*Text mining in R for the social sciences and digital humanities*](https://tm4ss.github.io/docs/index.html) by Andreas Niekler and Gregor Wiedemann --- ## What Are Geospatial Data? .pull-left[ Data with a direct spatial reference `\(\rightarrow\)` **geo-coordinates** - Information about geometries - Optional: Content in relation to the geometries Can be projected jointly in one single space - Allows data linking and extraction of substantial information ] .pull-right[ <img src="data:image/png;base64,#../img/fig_geometries.png" width="85%" style="display: block; margin: auto;" /> .tinyisher[Sources: OpenStreetMap / GEOFABRIK (2018), City of Cologne (2014), and the Statistical Offices of the Federation and the Länder (2016) / Jünger, 2019] ] --- ## [Mapping](https://cran.r-project.org/web/packages/mapsf/vignettes/mapsf.html) is so easy nowadays .pull-left[ ```r library(mapsf) mtq <- mf_get_mtq() mf_map(x = mtq) mf_map(x = mtq, var = "POP", type = "prop") mf_layout( title = "Population in Martinique", credits = "T. Giraud; Sources: INSEE & IGN, 2018" ) ``` ] .pull-right[ <img src="data:image/png;base64,#5_2_Outlook_files/figure-html/mapsf-print-1.png" style="display: block; margin: auto;" /> ] Example from: https://riatelab.github.io/mapsf/ --- ## 'Web development' using `R` These days, a lot of `R` packages provide tools originally developed for the web. For example: - [bookdown](https://pkgs.rstudio.com/bookdown/) enables you to publish books written in `R Markdown` online - [pkgdown](https://pkgdown.r-lib.org/) does the same for your own `R` packages - [blogdown](https://pkgs.rstudio.com/blogdown/l) is more general and helps you with creating websites (examples to follow) --- ## Shiny apps > Shiny is an R package that makes it easy to build interactive web apps straight from R. You can host standalone apps on a webpage or embed them in R Markdown documents or build dashboards. You can also extend your Shiny apps with CSS themes, htmlwidgets, and JavaScript actions. https://shiny.rstudio.com/ --- class: middle ## Example 1: Movie Explorer .center[https://shiny.rstudio.com/gallery/movie-explorer.html] --- class: middle ## Example 2: CRAN explorer .center[https://gallery.shinyapps.io/cran-explorer/] --- ## Writing your own `R` packages .pull-left[ At a certain point (not now!), you may want to consider writing your own `R` package - useful for creating reproducible code - great for distributing your work to others ] .pull-right[ <img src="data:image/png;base64,#../img/r_packages.jpg" width="1381" style="display: block; margin: auto;" /> [Read the book here!](https://r-pkgs.org/) ] --- class: middle ## It's straightforward in `RStudio` <img src="data:image/png;base64,#../img/new_package.png" width="75%" style="display: block; margin: auto;" /> --- ## Acknowledgements ❤️ All slides were created with the `R` package [`xaringan`](https://github.com/yihui/xaringan) which builds on [`remark.js`](https://remarkjs.com), [`knitr`](http://yihui.name/knitr), and [`R Markdown`](https://rmarkdown.rstudio.com). The exercises were created with the [`unilur` package](https://github.com/koncina/unilur). [`woRkshoptools`](https://stefanjuenger.github.io/woRkshoptools/)